<!DOCTYPE html>



  


<html class="theme-next muse use-motion" lang="zh-Hans">
<head>
  <meta charset="UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1"/>
<meta name="theme-color" content="#222">









<meta http-equiv="Cache-Control" content="no-transform" />
<meta http-equiv="Cache-Control" content="no-siteapp" />















  
  
  <link href="/%E5%BF%83%E5%BA%95%E7%9A%84%E5%B8%8C%E6%9C%9B/blog/lib/fancybox/source/jquery.fancybox.css?v=2.1.5" rel="stylesheet" type="text/css" />




  
  
  
  

  
    
    
  

  

  

  

  

  
    
    
    <link href="//fonts.googleapis.com/css?family=Lato:300,300italic,400,400italic,700,700italic&subset=latin,latin-ext" rel="stylesheet" type="text/css">
  






<link href="/%E5%BF%83%E5%BA%95%E7%9A%84%E5%B8%8C%E6%9C%9B/blog/lib/font-awesome/css/font-awesome.min.css?v=4.6.2" rel="stylesheet" type="text/css" />

<link href="/%E5%BF%83%E5%BA%95%E7%9A%84%E5%B8%8C%E6%9C%9B/blog/css/main.css?v=5.1.2" rel="stylesheet" type="text/css" />


  <meta name="keywords" content="mysql,java,数据库," />








  <link rel="shortcut icon" type="image/x-icon" href="/%E5%BF%83%E5%BA%95%E7%9A%84%E5%B8%8C%E6%9C%9B/blog/favicon.ico?v=5.1.2" />






<meta name="description" content="jdbc jdbc基础  步骤 导包 注册驱动 获取数据库连接对象 定义sql 执行sql 处理 释放资源  相关对象 Drivermanager  方法   Connection connection &#x3D; DriverManager.getConnection(url, properties);  &#x2F;* url&#x3D;jdbc:mysql:&#x2F;&#x2F;localhost:3306&#x2F;test2 user&#x3D;roo">
<meta property="og:type" content="article">
<meta property="og:title" content="jdbc">
<meta property="og:url" content="https://gitee.com/bhblinux/blog.git/2020/07/23/jdbc/index.html">
<meta property="og:site_name" content="Bhblinux个人博客">
<meta property="og:description" content="jdbc jdbc基础  步骤 导包 注册驱动 获取数据库连接对象 定义sql 执行sql 处理 释放资源  相关对象 Drivermanager  方法   Connection connection &#x3D; DriverManager.getConnection(url, properties);  &#x2F;* url&#x3D;jdbc:mysql:&#x2F;&#x2F;localhost:3306&#x2F;test2 user&#x3D;roo">
<meta property="article:published_time" content="2020-07-23T03:36:08.000Z">
<meta property="article:modified_time" content="2020-07-23T03:48:41.005Z">
<meta property="article:author" content="Bhblinux">
<meta property="article:tag" content="mysql">
<meta property="article:tag" content="java">
<meta property="article:tag" content="数据库">
<meta name="twitter:card" content="summary">



<script type="text/javascript" id="hexo.configurations">
  var NexT = window.NexT || {};
  var CONFIG = {
    root: '/心底的希望/blog/',
    scheme: 'Muse',
    sidebar: {"position":"left","display":"post","offset":12,"offset_float":12,"b2t":false,"scrollpercent":false,"onmobile":false},
    fancybox: true,
    tabs: true,
    motion: true,
    duoshuo: {
      userId: '0',
      author: '博主'
    },
    algolia: {
      applicationID: '',
      apiKey: '',
      indexName: '',
      hits: {"per_page":10},
      labels: {"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}
    }
  };
</script>



  <link rel="canonical" href="https://gitee.com/bhblinux/blog.git/2020/07/23/jdbc/"/>





  <title>jdbc | Bhblinux个人博客</title>
  














<meta name="generator" content="Hexo 4.2.1"></head>

<body itemscope itemtype="http://schema.org/WebPage" lang="zh-Hans">

  
  
    
  

  <div class="container sidebar-position-left page-post-detail ">
    <div class="headband"></div>

    <header id="header" class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-wrapper">
  <div class="site-meta ">
    

    <div class="custom-logo-site-title">
      <a href="/心底的希望/blog/"  class="brand" rel="start">
        <span class="logo-line-before"><i></i></span>
        <span class="site-title">Bhblinux个人博客</span>
        <span class="logo-line-after"><i></i></span>
      </a>
    </div>
      
        <p class="site-subtitle"></p>
      
  </div>

  <div class="site-nav-toggle">
    <button>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
      <span class="btn-bar"></span>
    </button>
  </div>
</div>

<nav class="site-nav">
  

  
    <ul id="menu" class="menu">
      
        
        <li class="menu-item menu-item-home">
          <a href="/%E5%BF%83%E5%BA%95%E7%9A%84%E5%B8%8C%E6%9C%9B/blog/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-home"></i> <br />
            
            首页
          </a>
        </li>
      
        
        <li class="menu-item menu-item-archives">
          <a href="/%E5%BF%83%E5%BA%95%E7%9A%84%E5%B8%8C%E6%9C%9B/blog/archives/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-archive"></i> <br />
            
            归档
          </a>
        </li>
      
        
        <li class="menu-item menu-item-categories">
          <a href="/%E5%BF%83%E5%BA%95%E7%9A%84%E5%B8%8C%E6%9C%9B/blog/categories" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-th"></i> <br />
            
            分类
          </a>
        </li>
      
        
        <li class="menu-item menu-item-tags">
          <a href="/%E5%BF%83%E5%BA%95%E7%9A%84%E5%B8%8C%E6%9C%9B/blog/tags/" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-tags"></i> <br />
            
            标签
          </a>
        </li>
      
        
        <li class="menu-item menu-item-about">
          <a href="/%E5%BF%83%E5%BA%95%E7%9A%84%E5%B8%8C%E6%9C%9B/blog/about" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-user"></i> <br />
            
            关于
          </a>
        </li>
      
        
        <li class="menu-item menu-item-search">
          <a href="/%E5%BF%83%E5%BA%95%E7%9A%84%E5%B8%8C%E6%9C%9B/blog/search" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-question-circle"></i> <br />
            
            搜索
          </a>
        </li>
      
        
        <li class="menu-item menu-item-commonweal">
          <a href="/%E5%BF%83%E5%BA%95%E7%9A%84%E5%B8%8C%E6%9C%9B/blog/404.html" rel="section">
            
              <i class="menu-item-icon fa fa-fw fa-heartbeat"></i> <br />
            
            公益404
          </a>
        </li>
      

      
    </ul>
  

  
</nav>



 </div>
    </header>

    <main id="main" class="main">
      <div class="main-inner">
        <div class="content-wrap">
          <div id="content" class="content">
            

  <div id="posts" class="posts-expand">
    

  

  
  
  

  <article class="post post-type-normal" itemscope itemtype="http://schema.org/Article">
  
  
  
  <div class="post-block">
    <link itemprop="mainEntityOfPage" href="https://gitee.com/bhblinux/blog.git/%E5%BF%83%E5%BA%95%E7%9A%84%E5%B8%8C%E6%9C%9B/blog/2020/07/23/jdbc/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="name" content="Bhblinux">
      <meta itemprop="description" content="">
      <meta itemprop="image" content="/%E5%BF%83%E5%BA%95%E7%9A%84%E5%B8%8C%E6%9C%9B/blog/images/avatar.gif">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Bhblinux个人博客">
    </span>

    
      <header class="post-header">

        
        
          <h1 class="post-title" itemprop="name headline">jdbc</h1>
        

        <div class="post-meta">
          <span class="post-time">
            
              <span class="post-meta-item-icon">
                <i class="fa fa-calendar-o"></i>
              </span>
              
                <span class="post-meta-item-text">发表于</span>
              
              <time title="创建于" itemprop="dateCreated datePublished" datetime="2020-07-23T11:36:08+08:00">
                2020-07-23
              </time>
            

            

            
          </span>

          

          
            
          

          
          

          

          

          

        </div>
      </header>
    

    
    
    
    <div class="post-body" itemprop="articleBody">

      
      

      
        <h1 id="jdbc"><a href="#jdbc" class="headerlink" title="jdbc"></a>jdbc</h1><blockquote>
<p>jdbc基础</p>
</blockquote>
<h2 id="步骤"><a href="#步骤" class="headerlink" title="步骤"></a>步骤</h2><ol>
<li>导包</li>
<li>注册驱动</li>
<li>获取数据库连接对象</li>
<li>定义sql</li>
<li>执行sql</li>
<li>处理</li>
<li>释放资源</li>
</ol>
<h2 id="相关对象"><a href="#相关对象" class="headerlink" title="相关对象"></a>相关对象</h2><ul>
<li><p>Drivermanager</p>
<blockquote>
<p>方法</p>
</blockquote>
<ol>
<li><p>Connection connection = DriverManager.getConnection(url, properties);</p>
</li>
<li><pre><code>/*
url=jdbc:mysql://localhost:3306/test2
user=root
password=123456
*/</code></pre></li>
</ol>
</li>
</ul>
<ul>
<li><p>Connection</p>
<blockquote>
<p>方法</p>
</blockquote>
<ol>
<li>createStatement</li>
</ol>
</li>
<li><p>statement</p>
<blockquote>
<p>方法</p>
</blockquote>
<ol>
<li>next() 游标向下移动一行</li>
<li>getxx() 获取数据</li>
</ol>
</li>
<li><p>Resultset</p>
</li>
<li><p>PreparedStatement</p>
</li>
</ul>

      
    </div>
    
    
    

    

    

    

    <footer class="post-footer">
      
        <div class="post-tags">
          
            <a href="/%E5%BF%83%E5%BA%95%E7%9A%84%E5%B8%8C%E6%9C%9B/blog/tags/mysql/" rel="tag"># mysql</a>
          
            <a href="/%E5%BF%83%E5%BA%95%E7%9A%84%E5%B8%8C%E6%9C%9B/blog/tags/java/" rel="tag"># java</a>
          
            <a href="/%E5%BF%83%E5%BA%95%E7%9A%84%E5%B8%8C%E6%9C%9B/blog/tags/%E6%95%B0%E6%8D%AE%E5%BA%93/" rel="tag"># 数据库</a>
          
        </div>
      

      
      
      

      
        <div class="post-nav">
          <div class="post-nav-next post-nav-item">
            
              <a href="/%E5%BF%83%E5%BA%95%E7%9A%84%E5%B8%8C%E6%9C%9B/blog/2020/07/22/mysql/" rel="next" title="mysql">
                <i class="fa fa-chevron-left"></i> mysql
              </a>
            
          </div>

          <span class="post-nav-divider"></span>

          <div class="post-nav-prev post-nav-item">
            
          </div>
        </div>
      

      
      
    </footer>
  </div>
  
  
  
  </article>



    <div class="post-spread">
      
    </div>
  </div>


          </div>
          


          
  <div class="comments" id="comments">
    
  </div>


        </div>
        
          
  
  <div class="sidebar-toggle">
    <div class="sidebar-toggle-line-wrap">
      <span class="sidebar-toggle-line sidebar-toggle-line-first"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-middle"></span>
      <span class="sidebar-toggle-line sidebar-toggle-line-last"></span>
    </div>
  </div>

  <aside id="sidebar" class="sidebar">
    
    <div class="sidebar-inner">

      

      
        <ul class="sidebar-nav motion-element">
          <li class="sidebar-nav-toc sidebar-nav-active" data-target="post-toc-wrap" >
            文章目录
          </li>
          <li class="sidebar-nav-overview" data-target="site-overview">
            站点概览
          </li>
        </ul>
      

      <section class="site-overview sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
          <img class="site-author-image" itemprop="image"
               src="/%E5%BF%83%E5%BA%95%E7%9A%84%E5%B8%8C%E6%9C%9B/blog/images/avatar.gif"
               alt="Bhblinux" />
          <p class="site-author-name" itemprop="name">Bhblinux</p>
           
              <p class="site-description motion-element" itemprop="description">个人博客系统</p>
          
        </div>
        <nav class="site-state motion-element">

          
            <div class="site-state-item site-state-posts">
              <a href="/%E5%BF%83%E5%BA%95%E7%9A%84%E5%B8%8C%E6%9C%9B/blog/archives/">
                <span class="site-state-item-count">3</span>
                <span class="site-state-item-name">日志</span>
              </a>
            </div>
          

          
            
            
            <div class="site-state-item site-state-categories">
              <a href="/%E5%BF%83%E5%BA%95%E7%9A%84%E5%B8%8C%E6%9C%9B/blog/categories/index.html">
                <span class="site-state-item-count">1</span>
                <span class="site-state-item-name">分类</span>
              </a>
            </div>
          

          
            
            
            <div class="site-state-item site-state-tags">
              
                <span class="site-state-item-count">3</span>
                <span class="site-state-item-name">标签</span>
              
            </div>
          

        </nav>

        

        <div class="links-of-author motion-element">
          
        </div>

        
        

        
        

        


      </section>

      
      <!--noindex-->
        <section class="post-toc-wrap motion-element sidebar-panel sidebar-panel-active">
          <div class="post-toc">

            
              
            

            
              <div class="post-toc-content"><ol class="nav"><li class="nav-item nav-level-1"><a class="nav-link" href="#jdbc"><span class="nav-number">1.</span> <span class="nav-text">jdbc</span></a><ol class="nav-child"><li class="nav-item nav-level-2"><a class="nav-link" href="#步骤"><span class="nav-number">1.1.</span> <span class="nav-text">步骤</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#相关对象"><span class="nav-number">1.2.</span> <span class="nav-text">相关对象</span></a></li></ol></li></ol></div>
            

          </div>
        </section>
      <!--/noindex-->
      

      

    </div>
  </aside>


        
      </div>
    </main>

    <footer id="footer" class="footer">
      <div class="footer-inner">
        <div class="copyright" >
  
  &copy; 
  <span itemprop="copyrightYear">2020</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">Bhblinux</span>
</div>


<div class="powered-by">
  由 <a class="theme-link" href="https://hexo.io" target="_blank" rel="noopener">Hexo</a> 强力驱动
</div>

<div class="theme-info">
  主题 -
  <a class="theme-link" href="https://github.com/iissnan/hexo-theme-next" target="_blank" rel="noopener">
    NexT.Muse
  </a>
</div>


        

        
      </div>
    </footer>

    
      <div class="back-to-top">
        <i class="fa fa-arrow-up"></i>
        
      </div>
    

  </div>

  

<script type="text/javascript">
  if (Object.prototype.toString.call(window.Promise) !== '[object Function]') {
    window.Promise = null;
  }
</script>









  












  
  <script type="text/javascript" src="/%E5%BF%83%E5%BA%95%E7%9A%84%E5%B8%8C%E6%9C%9B/blog/lib/jquery/index.js?v=2.1.3"></script>

  
  <script type="text/javascript" src="/%E5%BF%83%E5%BA%95%E7%9A%84%E5%B8%8C%E6%9C%9B/blog/lib/fastclick/lib/fastclick.min.js?v=1.0.6"></script>

  
  <script type="text/javascript" src="/%E5%BF%83%E5%BA%95%E7%9A%84%E5%B8%8C%E6%9C%9B/blog/lib/jquery_lazyload/jquery.lazyload.js?v=1.9.7"></script>

  
  <script type="text/javascript" src="/%E5%BF%83%E5%BA%95%E7%9A%84%E5%B8%8C%E6%9C%9B/blog/lib/velocity/velocity.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/%E5%BF%83%E5%BA%95%E7%9A%84%E5%B8%8C%E6%9C%9B/blog/lib/velocity/velocity.ui.min.js?v=1.2.1"></script>

  
  <script type="text/javascript" src="/%E5%BF%83%E5%BA%95%E7%9A%84%E5%B8%8C%E6%9C%9B/blog/lib/fancybox/source/jquery.fancybox.pack.js?v=2.1.5"></script>


  


  <script type="text/javascript" src="/%E5%BF%83%E5%BA%95%E7%9A%84%E5%B8%8C%E6%9C%9B/blog/js/src/utils.js?v=5.1.2"></script>

  <script type="text/javascript" src="/%E5%BF%83%E5%BA%95%E7%9A%84%E5%B8%8C%E6%9C%9B/blog/js/src/motion.js?v=5.1.2"></script>



  
  

  
  <script type="text/javascript" src="/%E5%BF%83%E5%BA%95%E7%9A%84%E5%B8%8C%E6%9C%9B/blog/js/src/scrollspy.js?v=5.1.2"></script>
<script type="text/javascript" src="/%E5%BF%83%E5%BA%95%E7%9A%84%E5%B8%8C%E6%9C%9B/blog/js/src/post-details.js?v=5.1.2"></script>



  


  <script type="text/javascript" src="/%E5%BF%83%E5%BA%95%E7%9A%84%E5%B8%8C%E6%9C%9B/blog/js/src/bootstrap.js?v=5.1.2"></script>



  


  




	





  





  






  





  

  

  

  

  

  

</body>
</html>
